import 'package:coinbaby/common/const/cosnt.dart';
import 'package:coinbaby/common/textstyle/textstyle.dart';
import 'package:flutter/material.dart';

class AutoBuyCell extends StatelessWidget {

  final int index;

  const AutoBuyCell({Key key, this.index}) : super(key: key);

  Widget _createRight() {
    Widget res;
    if(index == 0) {
      res = Container(
        margin: const EdgeInsets.only(top: 15),
        padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 2),
        decoration: BoxDecoration(
          color: const Color(0xfff3f3f3),
          borderRadius: BorderRadius.circular(10)
        ),
        child: Row(
          children: <Widget>[
            Image.asset("assets/renshu.png"),
            SizedBox(width: 2.5,),
            Text("123", style: AppFont.textStyle(11, AppColor.font333),),
          ],
        ),
      );
    } else {
      res = Container(
        margin: const EdgeInsets.only(top: 15),
        padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 2),
        decoration: BoxDecoration(
          color: AppColor.red,
          borderRadius: BorderRadius.circular(10)
        ),
        child: Text("即将上线", style: AppFont.textStyle(11, Colors.white),),
      );
    }

    return res;
  }
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(left: 15, right: 15, bottom: 15),
      height: 117,
      padding: const EdgeInsets.only(left: 15, right: 13.5),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(13)
      ),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text("7.6%", style: AppFont.textStyle(27, AppColor.font333, fontWeight: FontWeight.bold),),
              Text("AI预测月化利率", style: AppFont.textStyle(12, AppColor.fontgrey),)
            ],
          ),
          SizedBox(width: 25,),
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: <Widget>[
              Text("1策略", style: AppFont.textStyle(15, AppColor.font333, fontWeight: FontWeight.bold),),
              SizedBox(height: 6,),
              Row(
                children: <Widget>[
                  _TabView(title: "高抛低吸",),
                  SizedBox(width: 10,),
                  _TabView(title: "震荡利器",),
                ],
              ),
              SizedBox(height: 6,),
              Row(
                children: <Widget>[
                  Image.asset("assets/icon_huobi.png"),
                  SizedBox(width: 3,),
                  Text("火币", style: AppFont.textStyle(11, AppColor.fontgrey),)
                ],
              ),
            ],
          ),
          Spacer(),
          _createRight()
        ],
      ),
    );
  }
}

class _TabView extends StatelessWidget {
  
  final String title;

  const _TabView({Key key, this.title}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1.5),
      decoration: BoxDecoration(
        color: AppColor.blue.withOpacity(0.12),
        borderRadius: BorderRadius.circular(2)
      ),
      child: Text(title, style: AppFont.textStyle(12, AppColor.blue),),
    );
  }
}